#include "Window.h"
#include "Log.h"

namespace SCION_WINDOWING
{
  void Window::CreateNewWindow(Uint32 flags)
  {
    m_pWindow = SCION_UTIL::WindowPtr(SDL_CreateWindow(m_sTitle.c_str(), m_Width, m_Height, flags)); // m_XPos, m_YPos,
    if (!m_pWindow)
    {
      std::string error = SDL_GetError();
      SCION_ERROR("Failed to create the Window: " + error);
      return;
    }
  }

  Window::Window(const std::string title, int width, int height, int x_pos, int y_pos, bool v_sync, Uint32 flags) : m_pWindow{nullptr}, m_GLContext{}, m_sTitle{title}, m_Width{width}, m_Height{height}, m_XPos{x_pos}, m_YPos{y_pos}, m_WindowFlags{flags}
  {
    CreateNewWindow(flags);
    if (v_sync)
    {
      if (!SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"))
      {
        SCION_ERROR("Failed to enable VSYNC!");
      }
      SCION_INFO("Window Created Successfully!");
    }
  }

  Window::~Window()
  {
  }
  // std::string Window::GetWindowName()
  // {
  //   // m_sTitle = name;
  //   SDL_SetWindowTitle(m_pWindow.get(), m_sTitle.c_str());
  //   return m_sTitle;
  // }

}